package com.lkd.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lkd.dto.VmTypeDto;
import com.lkd.entity.VmType;
import com.lkd.mapper.VmTypeMapper;
import com.lkd.service.IVmTypeService;
import com.lkd.vo.PageBean;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 售货机类型表 服务实现类
 * </p>
 *
 * @author xiaotao
 * @since 2025-10-15
 */
@Service
public class VmTypeServiceImpl extends ServiceImpl<VmTypeMapper, VmType> implements IVmTypeService {
    /**
     * 设备类型搜索
     *
     * @param vmTypeDto
     * @return
     */
    @Override
    public PageBean<VmType> search(VmTypeDto vmTypeDto) {
        //1.设置分页参数
        Page<VmType> vmTypePage = new Page<>(vmTypeDto.getPageIndex(), vmTypeDto.getPageSize());

        //2.设置业务参数
        LambdaQueryWrapper<VmType> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(StrUtil.isNotBlank(vmTypeDto.getName()), VmType::getName, vmTypeDto.getName());

        //3.执行分页查询
        Page<VmType> page = this.page(vmTypePage, wrapper);

        //4.返回分页结果
        return new PageBean<>(page);
    }
}
